import axios from 'axios'

// const mid = JSON.parse(window.localStorage.getItem('item')).id
const mid = 11

export const addShoppingCart = ({goodname, goodprice, goodnum, gooddesc, picurl}) => {
   return new Promise((success, fail) => {
    axios.get("/huainianwang/shoppingCart/app/addShoppingCart?mid=" + mid+"&goodname="+ goodname+"&goodprice="+goodprice+"&goodnum="+goodnum+"&gooddesc="+gooddesc + "&picurl="+picurl+"")
    .then(function(res){
        success(res)
    }).catch(function(error){
        fail(error)
    })
   })
}

export const delShoppingCart = (sid) => {
    return new Promise((success, fail) => {
        axios.get("/huainianwang/shoppingCart/app/delShoppingCart", {params: {sid}})
        .then(function(res){
            success(res)
        }).catch(function(error){
            fail(error)
        })
    })
}

 export const updateMemorialCs = (musicname, musicurl, props) => {
    return new Promise((success, fail) => {
        axios.post("/huainianwang/memorialConstruction/app/updateMemorialCs", {
          mid: mid,
          props:JSON.stringify(props),
          musicname: musicname,
          musicurl: musicurl,
          picbk: 'picbk'
        })
        .then(function(res){
            success(res)
        }).catch(function(error){
            fail(error)
        })
    })
 }

 export const getMemorialCs = () => {
  return new Promise((success, fail) => {
      axios.get("/huainianwang/memorialConstruction/app/getMemorialCs?mid="+mid+"")
      .then(function(res){
          success(res)
      }).catch(function(error){
          fail(error)
      })
  })
}

export const saveMemorialCs = (musicname, musicurl, props) => {
    return new Promise((success, fail) => {
        axios.get("/huainianwang/memorialConstruction/app/saveMemorialCs", {
            mid: 335,
            musicname,
            musicurl,
            props:JSON.stringify(props),
            picbk: 'picbk'
        })
        .then(function(res){
            success(res)
        }).catch(function(error){
            fail(error)
        })
    })
  }

  export const getSoppingCart = () => {
    return new Promise((success, fail) => {
        axios.get("/huainianwang/shoppingCart/app/getShoppingCartByMid", {params: {mid}})
        .then(function(res){
            success(res)
        }).catch(function(error){
            fail(error)
        })
    })
  }
